/*
 * @Author: evanxu evanxu8023@163.com
 * @Date: 2022-09-21 08:32:48
 * @LastEditors: EvanXU evanxu8023@163.com
 * @LastEditTime: 2024-06-21 17:14:18
 * @FilePath: \program\USER\led.h
 * @Description: 
 * 
 * Copyright (c) 2022 by evanxu evanxu8023@163.com, All Rights Reserved. 
 */
#ifndef _led_h_
#define _led_h_

/* 文件调用 ----------------------------------------------------------------*/
#include "sys.h"

/* 类型定义 ------------------------------------------------------------------*/
typedef enum
{
  LED_OFF = 0,
  LED_ON  = 1,
  LED_TOGGLE = 2,
}LEDState_TypeDef;

/* 宏定义  ------------------------------------------------------------------*/
#define LED_RUN						(uint8_t)0x01
#define LED1						(uint8_t)0x02
#define BEEP						(uint8_t)0x04

#define LED_RUN_PIN						GPIO_PINS_1
#define LED_RUN_GPIO					GPIOA
#define LED_RUN_GPIO_CRM_CLK  			(crm_periph_clock_type)CRM_GPIOA_PERIPH_CLOCK
#define BEEP_PIN						 GPIO_PINS_2
#define BEEP_GPIO						 GPIOA
#define BEEP_GPIO_CRM_CLK     			(crm_periph_clock_type)CRM_GPIOA_PERIPH_CLOCK

#define LED_RUN_OFF						(LED_RUN_GPIO->scr = LED_RUN_PIN)
#define LED_RUN_ON						(LED_RUN_GPIO->clr = LED_RUN_PIN)
#define LED_RUN_TOGGLE					(LED_RUN_GPIO->odt ^= LED_RUN_PIN)

#define BEEP_ON							(BEEP_GPIO->scr = BEEP_PIN)
#define BEEP_OFF						(BEEP_GPIO->clr = BEEP_PIN)
#define BEEP_TOGGLE						(BEEP_GPIO->odt ^= BEEP_PIN)


/* 函数声明 --------------------------------------------------------------------*/
void led_gpio_init(void);
void led_state_set(uint8_t LEDx,LEDState_TypeDef state);
void beep_onoff(uint16_t cnt, uint16_t on_time, uint16_t off_time);

void beep_key_trig(uint16_t cnt);
void beep_reset_cnt(void);
void beep_ctrl_enable(u8 sta);

#endif


